JBoss Community Archive (Read Only)

SwitchYard 0.7

Remote Invoker

NOTE: This functionality is experimental in SwitchYard 0.6 and will be extended in the 0.7 release.  API changes may result from this activity, but the basic functionality of the client will remain.

The RemoteInvoker serves as a remote invocation client for SwitchYard services.  It allows non-SwitchYard applications to invoke any service in SwitchYard which uses a <binding.remote> binding.  It is also used by the internal clustering channel to facilitate intra-cluster communication between instances.

Using the RemoteInvoker

RemoteInvoker and supporting classes can be included in your application via the following Maven dependency:

<dependency>
   <groupId>org.switchyard</groupId>
   <artifactId>switchyard-remote</artifactId>
   <version> <!-- SY version goes here (e.g. 0.6.0.Beta2) --> </version>
</dependency>

Each instance of SY includes a special context path called "switchyard-remote" which is bound to the default HTTP listener in AS 7.  The initial version of RemoteInvoker supports communication with this endpoint directly.  Here's an example of invoking an in-out service in SY using the HttpInvoker:

public class MyClient {
    public static void main(String[] args) throws Exception {
        RemoteInvoker invoker = new HttpInvoker("http://localhost:8080/switchyard-remote");
        Offer offer = new Offer();
        offer.setAmount(100);
        offer.setItem("honda");
        
        RemoteMessage msg = invoker.invoke(new RemoteMessage()
            .setContext(new DefaultContext())
            .setService(new QName("urn:com.example.switchyard:remote", "Dealer"))
            .setContent(offer));
        
        Deal deal = (Deal)msg.getContent();
        System.out.println("It's a deal? " + deal.isAccepted());
    }
}

Coming Soon

The following features are planned for SwitchYard 0.7:

  • The ability to use a runtime registry client instead of an HTTP endpoint URL.  In this scenario, the client connects to the shared runtime registry underneath the covers and retrieves the endpoint URL for remote services.

  • Out-of-the box load balancing strategies such as Round Robin.

  • The ability to specify a custom load balancing strategy for the client.

  • Cleaner, more powerful API

JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-13 09:48:11 UTC, last content change 2012-11-01 01:17:34 UTC.